// index.js
// 获取应用实例
const app = getApp()
var t = getApp(), a = t.requirejs("core"), e = t.requirejs("wxParse/wxParse"), i = t.requirejs("biz/diypage"), s = t.requirejs("biz/diyform"), n = t.requirejs("biz/goodspicker"), o = (t.requirejs("foxui"), 
t.requirejs("jquery"));

Page({
  data: {
    current:0,
    statusbar:10,
    barHeight:40,
    tabList:[],
    cid:'',//跳转到 板块传递的cid
  },
  onLoad() {
    let that=this;
    wx.getSystemInfo({
      success:function (res) {
        that.setData({
          statusbar :res.statusBarHeight,
          barHeight: wx.getMenuButtonBoundingClientRect().height+((wx.getMenuButtonBoundingClientRect().top- res.statusBarHeight)*2),
        })
      }
    });
    this.getData();
  },
  goHome(){
    wx.switchTab({
      url: '/pages/index/index',
    })
  },
  getData(){
    var t = this;
    a.post("sns/get_list", {}, function(a) {
      t.setData({
        category:a.category,
        recommands:a.recommands
      })
    });
  },
  back(){
    wx.navigateBack().catch(e=>{
      wx.switchTab({
        url: '/pages/index/index',
      })
    })
  },
  tabC(e){
    if(this.data.current==e.currentTarget.dataset.index)return
    this.setData({
      current:e.currentTarget.dataset.index,
    });
    if(this.data.current==1){
      // this.setData({
      //   cid:'',
      // })
    }
    if(this.data.current==2){
      this.mineHome = this.selectComponent("#mineHome");
    }
    
  },
  changeCid(e){
    this.setData({
      cid:e.detail
    })
  },
  goEssence(e){
    let index=e.currentTarget.dataset.index;
    wx.navigateTo({
      url: './essence/index?bid='+e.currentTarget.dataset.id+'&info='+encodeURIComponent(JSON.stringify(this.data.recommands[index])),
    })
  },
  onReady(){
    
  },
  onShow(){
    if(this.data.current==2){
      this.mineHome.onshow()
    }
  },
  goSection(e){
    this.setData({
      cid:e.currentTarget.dataset.cid,
      current:1,
    })
  }
})
